package com.lznAdmin.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lznAdmin.system.entity.SysRolePermission;
import com.lznAdmin.system.mapper.SysRolePermissionMapper;
import com.lznAdmin.system.service.SysRolePermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: lznAdmin-pro
 * @description:
 * @author: lzn
 * @create: 2022-01-19 17:19
 **/
@Service
@Slf4j
public class SysRolePermissionImpl extends ServiceImpl<SysRolePermissionMapper, SysRolePermission> implements SysRolePermissionService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Boolean updatePerIdsById(List<SysRolePermission> sysRolePermissionList) {
        Long roleId = sysRolePermissionList.get(0).getRoleId();
        if (roleId != null) {
            int b = baseMapper.deleteByRoleId(roleId);
            log.info(String.valueOf(b));
            return this.saveBatch(sysRolePermissionList);
        }
        return false;
    }
}
